// components/product/index.js
const app = getApp()
Component({
  /**
   * 组件的属性列表
   */
  properties: {
    product:Object,
    model:Number
  },

  /**
   * 组件的初始数据
   */
  data: {
    img:''
  },

  /**
   * 组件的方法列表
   */
  methods: {
    detail() {
      console.log("model:"+this.properties.model)
      if (this.properties.model==1) {
        app.globalData.productDetail = this.properties.product
        wx.navigateTo({
          url: '../../../pages/mall/productChange/index',
        })
        return;
      }
      wx.navigateTo({
        url: '../../../pages/mall/detail/index?productId=' +
          this.properties.product.productId,
      })
    }
  },
  attached() {
    let imgs = this.properties.product.imgs.split(',')
    this.setData({
      img:imgs[0]
    })
  }
})
